import allure
from page_base.page_base import Base
from page_object.page_roncoo_pay_login import PageLogin
from page_element.el_Roncoo import *
from utils.timer import sleep
import logging

class AddPerm(PageLogin):
    def add_perm(self,permname,permbiao,permdesc):
        self.page_login('admin','123456')
        with allure.step(f'点击权限管理'):
            self.click(Perm.per_a)
        with allure.step(f'点击添加权限'):
            self.click(Perm.add_per)
        with allure.step(f'输入权限名称：{permname}'):
            self.send_keys(Perm.per_name,permname)
        with allure.step(f'输入权限标识：{permbiao}'):
            self.send_keys(Perm.per_biao,permbiao)
        with allure.step(f'输入权限描述：{permdesc}'):
            self.send_keys(Perm.per_desc,permdesc)
        with allure.step('点击保存'):
            self.click(Perm.per_submit)

        # 断言
        with allure.step("验证添加成功"):
            num = self.text(Perm.per_num)
            assert '7' in num, '断言失败(验证失败)'
            print(f'断言的内容:{num}')
            logging.info(f'断言的内容:共{num}条')
        #删除
        with allure.step('点击删除'):
            self.click(Perm.delete_per)
        with allure.step('点击确定'):
            self.click(Perm.sure_pselete)
